package com.shoppingmall.adapter;

import android.widget.CompoundButton;

import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.zyh.toolslib.utils.ToastUtils;
import com.shoppingmall.R;
import com.shoppingmall.bean.ScanHistoryBean;

import java.util.List;

import androidx.annotation.NonNull;

/**
 * 2020/3/16
 * 描述：浏览历史
 */
public class ScanHistoryAdapter extends BaseSectionQuickAdapter<ScanHistoryBean, BaseViewHolder> {

    private boolean modifyState;

    public ScanHistoryAdapter(List<ScanHistoryBean> data) {
        super(R.layout.item_mine_collect_goods, R.layout.item_mine_scan_history_header, data);
    }

    public void setModifyState(boolean modifyState) {
        this.modifyState = modifyState;
    }

    @Override
    protected void convertHead(BaseViewHolder helper, ScanHistoryBean item) {
        helper.setText(R.id.tv_scan_date, item.header);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, ScanHistoryBean item) {
//        helper.setText(R.id.tv_store_name, (String) item.t);
        helper.setGone(R.id.cb_collect, modifyState);
        helper.setOnCheckedChangeListener(R.id.cb_collect, new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                item.setChoosed(b);
            }
        });
    }

    private OnSelectListener onSelectListener;

    public void setOnSelectListener(OnSelectListener onSelectListener) {
        this.onSelectListener = onSelectListener;
    }

    public interface OnSelectListener {
        void select(ScanHistoryBean bean);
    }
}
